package com.zy.gmall0401.config;

import com.zy.gmall0401.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//使用拦截器 这是一个拦截器拦截登陆的用户地址 到认证中心去验证token
@Component
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Autowired
    AuthInterceptor authInterceptor;
    @Override
    //重写拦截器的方法
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor).addPathPatterns("/**"); //拦截所有的请求
        super.addInterceptors(registry);
    }



}
